import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

enum Api {
  list = '/system-service/accessLog/page',
  delete = '/system-service/accessLog/delete',
  clean = '/system-service/accessLog/clean',
  exportXlsUrl = 'sys/accessLog/exportXls',
  importExcelUrl = 'sys/accessLog/importExcel',
  deleteBatch = '/system-service/accessLog/deleteBatch',
}

/**
 * 导出api
 */
export const getExportUrl = Api.exportXlsUrl;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcelUrl;
/**
 * 查询任务列表
 * @param params
 */
export const getLogList = (params) => { return defHttp.get({ url: Api.list, params });};

/**
 * 删除任务
 * @param params
 */
 export const cleanLog = (handleSuccess) => {
  return defHttp.delete({ url: Api.clean}, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};

/**
 * 删除任务
 * @param params
 */
export const deleteLog = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};

/**
 * 批量删除任务
 * @param params
 */
export const batchDeleteLog = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};

